home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Mac Game Programming Gurus
/
TricksOfTheMacGameProgrammingGurus.iso
/
More Source
/
Libraries
/
SAT 2.3b4
/
Misc
/
FaceFromPICT.p
< prev
next >
Wrap
Text File
|
1995-05-01
|
1KB
|
61 lines
unit FaceFromPICT;
interface
uses
{$IFC UNDEFINED THINK_PASCAL}
Types, QuickDraw, Memory, Resources, ToolUtils,
{$ENDC}
SAT;
function GetFaceFromPICT (colorPICTid, bwPICTid, maskPICTid: integer): FacePtr;
implementation
{No error checking yet!}
function GetFaceFromPICT (colorPICTid, bwPICTid, maskPICTid: integer): FacePtr;
var
bounds: Rect;
thePICT, maskPICT: PicHandle;
theFace: FacePtr;
savePort: SATPort;
begin
SATGetPort(savePort);
{Get PICTs}
{IDEA: It should really check if the PICT it loads was loaded already, and if it was, don't dispose it.}
if gSAT.initDepth > 1 then
thePICT := GetPicture(colorPICTid)
else
thePICT := GetPicture(bwPICTid);
maskPICT := GetPicture(maskPICTid);
bounds := thePICT^^.picFrame;
OffsetRect(bounds, -bounds.left, -bounds.top); {onödigt för det gör NewFace åt oss.}
if (thePICT = nil) or (maskPICT = nil) then
begin
GetFaceFromPICT := nil;
exit(GetFaceFromPICT);
end;
{Create face}
theFace := SATNewFace(bounds);
{Draw in the face}
SATSetPortFace(theFace);
DrawPicture(thePICT, bounds);
SATSetPortMask(theFace);
DrawPicture(maskPICT, bounds);
{Tell SAT that we are done}
SATChangedFace(theFace);
{Get rid of the PICTs}
ReleaseResource(Handle(thePICT));
ReleaseResource(Handle(maskPICT));
{Return the face.}
GetFaceFromPICT := theFace;
SATSetPort(savePort);
end;
end.